#pragma once
#include <QtWidgets/QMainWindow>
#include<qpainter.h>
#include<QVector>
#include "ui_snake.h"
#include<QRandomGenerator>

class snake : public QMainWindow
{
    Q_OBJECT

public:
    explicit snake(QWidget *parent = Q_NULLPTR);
    ~snake();
    void paintEvent(QPaintEvent* event);
    void initsnake();
    QRect CreateRect();
    QRect CreateRect2();
    void IsEat();
    void IsEat2();
    void IsHit();

private slots:
    void snake_update();

private:
    Ui::snakeClass *ui;
    QVector<QRect> vsnakeRect;
    QRect snakeHead;
    void keyPressEvent(QKeyEvent* key);
    QTimer* timer;
    bool blsRun;
    bool blsOver;
    QString sDisplay;
    int nDirection;
    QRect food;
    QRect food2;
    int nScore;
    QString scoreLabel;
    int speed;
};
